package service

import (
	"core/coreutil"
	"fmt"
	"time"
)

const CAPTCHAPrex = ""

type captchaStore struct {

	// Set sets the digits for the captcha id.

}

func (p captchaStore) Set(id string, digits []byte) {
	var str, err = coreutil.RedisUtil.Set(CAPTCHAPrex+id, digits, time.Hour).Result()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(str)
	}

}

// Get returns stored digits for the captcha id. Clear indicates
// whether the captcha must be deleted from the store.
func (p captchaStore) Get(id string, clear bool) (digits []byte) {
	var r, _ = coreutil.RedisUtil.Get(CAPTCHAPrex + id).Bytes()
	return r
}
